<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2021/12/28 16:46
 * Desc:
 */
class Model_Provider_Api_Hotel
{
    private $api = null;
    private $partner_id = null;
    private $app_id = 'AKIDekwdCbS7Lb3yqPEaUw5uqVYkagrgoCtMnd32';
    private $app_secret = 'f0t6chnuCxF7Yjfou5o29L5dqiD88P9pOivkcPzw';
    private $api_url = 'http://fx.stccs.com.cn/api/';
    private $log_path = 'supplier_provider.hotel_log';

    public function __construct($partnerId='',$log_path='supplier_provider.hotel_log')
    {
        $this->partner_id = $partnerId;
        $this->api = new Model_Provider_Api_Stapi($this->app_id, $this->app_secret, $this->api_url);
        $this->log_path = $log_path;
    }

    public function scenic_hotel_list($params)
    {
        return $this->request($params, 'product/hotel/hotelList');
    }

    public function product_room_list($params)
    {
        return $this->request($params, 'product/hotel/list');
    }

    public function product_room_calendar($params)
    {
        return $this->request($params, 'product/hotel/calendar');
    }

    public function product_room_change($params)
    {
        $this->partner_id = $params['partner_id'];
        return $this->request($params, 'product/hotel/productChange');
    }

    public function verify_order($params)
    {
         return $this->request($params, 'order/hotel/verify');
    }

    public function create_order($params)
    {
        return $this->request($params, 'order/hotel/create');
    }

    public function close_order($params)
    {
        return $this->request($params, 'order/hotel/close');
    }

    public function pay_order($params)
    {
        return $this->request($params, 'order/hotel/pay');
    }

    public function request($params, $request_uri)
    {
        $params['partnerId'] = $this->partner_id;
        $params['providerChannel'] = Model_Zwyhotel::$providerChannel;
        $requestId = microtime(true);
        $logTitle = $request_uri."({$requestId})";
        Model_Tool_Log::write($this->log_path, json_encode($params), '发起请求：'.$logTitle);
        $rtn = $this->api->http($params, $request_uri);
        Model_Tool_Log::write($this->log_path, json_encode($rtn), '请求结果：'.$logTitle);
        return $rtn;
    }


}